<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <header th:replace="header::html"></header>
</head>
<body>
<form class="layui-form layui-form-pane" action="/expenditure/addExpenditure" method="post">
    <div class="layui-form-item">
        <label class="layui-form-label">支出名目</label>
        <div class="layui-input-block">
            <input type="text" name="title" required  lay-verify="required" placeholder="请输入支出名目" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">名字</label>
        <div class="layui-input-block">
            <input type="text" name="name" required lay-verify="required" placeholder="请输入姓名" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">支出金额</label>
        <div class="layui-input-block">
            <input type="text" name="money" required lay-verify="required" placeholder="请输入支出金额" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">支付方式</label>
        <div class="layui-input-block">
            <select name="paymode" lay-verify="">
                <option value="">请选择一个支付方式</option>
                <option value="微信">微信</option>
                <option value="支付宝">支付宝</option>
                <option value="数字货币">数字货币</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-block">
            <input type="text" name="remarks" required lay-verify="required" placeholder="请输入备注" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">时间</label>
        <div class="layui-input-block">
            <input type="text" name="time" id="time1" required lay-verify="required" placeholder="请选择时间" autocomplete="off" class="layui-input">
        </div>
    </div>


    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>

</form>

<script>
    //Demo
    layui.use('form', function(){
        var form = layui.form;

        //监听提交
        form.on('submit(formDemo)', function(data){
            $ = layui.jquery;
            $.ajax({
                url:"/expenditure/addExpenditure",    //数据接口
                type:"POST",            //提交方式
                contentType: "application/json; charset=utf-8",        //定义网络文件的类型和网页的编码，决定浏览器将以什么形式、什么编码读取这个文件
                data:JSON.stringify(data.field),
                dataType:'json',        //数据类型
                success:function(result){
                    layer.alert("添加成功", {icon: 6},function (index1) {
                        layer.close(index1);
                        location.reload()       //当前页面刷新
                        parent.location.reload();   //父级页面刷新
                        var index = parent.layer.getFrameIndex(window.name);    //获取当前页面的索引值(被父级索引的值)
                        parent.layer.close(index);  //关闭子页面
                    });
                }
            })
            return false;
        });
    });

</script>
<script src="/static/build/layui.js"></script>
<script>
    layui.use('laydate', function(){
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#time1' //指定元素

        });
    });
</script>
</body>
</html>